package com.tchy.cloud.controller;

import com.tchy.cloud.entity.ABankEntity;
import com.tchy.cloud.entity.AConsultantVodEntity;
import org.apache.log4j.Logger;
import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
import org.jeecgframework.core.common.model.json.AjaxJson;
import org.jeecgframework.core.common.model.json.DataGrid;
import org.jeecgframework.core.common.service.CommonService;
import org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil;
import org.jeecgframework.core.util.MyBeanUtils;
import org.jeecgframework.tag.core.easyui.TagUtil;
import org.jeecgframework.tag.vo.datatable.SortDirection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 直播信息维护
 */
@Controller
@RequestMapping("/vodController")
public class VodController {
    private static final Logger logger = Logger.getLogger(AConsultantVodEntity.class.getName());

    @Autowired
    private CommonService commonService;

    /**
     * 直播信息列表页面跳转
     *
     * @return
     */
    @RequestMapping(params = "index")
    public ModelAndView index() {
        return new ModelAndView("clound/vod/index");
    }

    /**
     * 直播信息列表数据展示
     *
     * @param vod
     * @param request
     * @param response
     * @param dataGrid
     */
    @RequestMapping(params = "datagrid")
    public void datagrid(AConsultantVodEntity vod, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
        CriteriaQuery cq = new CriteriaQuery(AConsultantVodEntity.class, dataGrid);
        cq.addOrder("consultantId", SortDirection.desc);
        cq.add();
        // 查询条件组装
        HqlGenerateUtil.installHql(cq, vod, request.getParameterMap());
        commonService.getDataGridReturn(cq, true);
        TagUtil.datagrid(response, dataGrid);
    }

//    /**
//     * 新增或编辑页面跳转
//     *
//     * @param aBankEntity
//     * @param req
//     * @return
//     */
//    @RequestMapping(params = "addorupdateView")
//    public ModelAndView addorupdateView(ABankEntity aBankEntity, HttpServletRequest req) {
//        if (aBankEntity.getId() != null) {
//            aBankEntity = commonService.getEntity(ABankEntity.class, aBankEntity.getId());
//        }
//        req.setAttribute("bank", aBankEntity);
//        return new ModelAndView("clound/bank/addorupdateView");
//    }
//
//
//    /**
//     * 新增及修改的数据处理
//     * @param aBankEntity
//     * @return
//     */
//    @RequestMapping(params = "saveorupdate", method = RequestMethod.POST)
//    @ResponseBody
//    public AjaxJson saveorupdate(ABankEntity aBankEntity) {
//        AjaxJson j = new AjaxJson();
//        try {
//            if (aBankEntity.getId() != null) {//修改
//                ABankEntity entity = commonService.get(ABankEntity.class, aBankEntity.getId());
//                MyBeanUtils.copyBeanNotNull2Bean(aBankEntity, entity);
//                commonService.saveOrUpdate(entity);
//            } else {//保存
//                commonService.save(aBankEntity);
//            }
//            j.setMsg("操作成功");
//        } catch (Exception e) {
//            logger.error(e);
//            j.setMsg("操作失败");
//        }
//        return j;
//    }

}







